package com.cosina.game.crystallight.ui.battle;

import java.util.ArrayList;
import java.util.List;

import android.graphics.Bitmap;

import com.cosina.game.crystallight.data.CrystalInfo;
import com.cosina.game.crystallight.model.crystal.Crystal;
import com.cosina.game.crystallight.ui.ResourceManager;
import com.cosina.game.crystallight.util.BitmapUtil;

public class CrystalResouce {
	
	public static Bitmap[] rect = new Bitmap[4];
	public static Bitmap[] speedBar;
	public static Bitmap[] rangeBar;
	public static List<Bitmap> crystalPart = new ArrayList<Bitmap>(64);
	public static Bitmap[] highLightCrystal;
	public static void init(){
		rect[0] = get("c1.png");
		rect[1] = get("c2.png");
		rect[2] = get("c3.png");
		rect[3] = get("c4.png");
		
		for(int i = 5; i<21; i++){
			Bitmap bitmap = get("c" + i + ".png");
			for(Bitmap eachPart : BitmapUtil.cut(bitmap, 4, -1)){
				crystalPart.add(eachPart);
			}
		}
		{
			Bitmap someBitmap = get("pb_fs.png");
			speedBar = BitmapUtil.cut(someBitmap, 8, -1);
		}
		{
			Bitmap someBitmap = get("pb_rad.png");
			rangeBar = BitmapUtil.cut(someBitmap, 8, -1);
		}
		
		highLightCrystal = BitmapUtil.cut(BitmapUtil.clearBlack(ResourceManager.getNoCahce("img/cardinal/crystals/hl.jpg")), 5, -1);
	}

	
	public static Bitmap getBitmap(Crystal crystal){
		if(crystal.level == CrystalInfo.MIN_LEVEL){
			return rect[crystal.color];
		}else{
			return CrystalResouce.crystalPart.get((crystal.level - 1)* 16 + crystal.color*4);
		}
	}
	
	static final String path = "img/cardinal/crystals/";
	
	public static Bitmap get(String name){
		return ResourceManager.getNoCahce(path + name);
	}
}
